Skip to content

feat: collect API request/response data in error reporter#201

Merged
kfirstri merged 7 commits intomainfrom
claude/enhance-error-reporter-mu1ZQ
Feb 8, 2026
Merged

feat: collect API request/response data in error reporter#201
kfirstri merged 7 commits intomainfrom
claude/enhance-error-reporter-mu1ZQ

Conversation

@kfirstri
Copy link
Collaborator

@kfirstri kfirstri commented Feb 7, 2026

Note

Description

This PR enhances API error telemetry by automatically capturing comprehensive request and response details when ApiError is thrown. The error reporter now extracts HTTP method, URL, status code, request body, and response body directly from ApiError instances, eliminating the need for manual context setting and providing richer debugging information for production API failures.

Related Issue

Fixes #185

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Other (please describe):

Changes Made

  • Extended ApiError class with new properties: requestUrl, requestMethod, requestBody, responseBody, and statusCode
  • Added captureRequestBody() hook to base44Client that clones requests and stores body in options.context.__requestBody for later extraction
  • Updated ApiError.fromHttpError() to extract request URL, method, body (from context), and response body from HTTPError instances
  • Modified ErrorReporter.buildProperties() to automatically extract API data from ApiError instances and include as telemetry properties (api_request_url, api_request_method, api_request_body, api_response_body, api_status_code)
  • Removed unused manual ErrorContext.api field in favor of automatic extraction pattern
  • Updated ApiErrorResponseSchema to handle nullable fields (details, traceback, extra_data) for more robust API error parsing
  • Added comprehensive test coverage with 5 new test cases covering all new properties, extraction logic, edge cases, and non-JSON responses

Testing

  • I have tested these changes locally
  • I have added/updated tests as needed
  • All tests pass (bun test)

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (if applicable)
  • My changes generate no new warnings
  • I have updated AGENTS.md if I made architectural changes

Additional Notes

This change is fully backwards-compatible and improves observability for API errors without requiring any changes to existing error handling code. The telemetry now automatically includes five new properties when an ApiError is captured: api_request_url, api_request_method, api_request_body, api_response_body, and api_status_code. The request body capture uses request cloning to avoid consuming the original request stream.


🤖 Generated by Claude | 2026-02-08 17:32 UTC

When an ApiError is thrown, the error reporter now automatically
extracts request URL, method, status code, and response body from
the error and includes them in telemetry. This removes the unused
manual ErrorContext.api field in favor of auto-extraction from
ApiError instances in buildProperties.

https://claude.ai/code/session_01WsgRcUXSBY5v1TppPoDdwZ
@github-actions
Copy link
Contributor

github-actions bot commented Feb 7, 2026

🚀 Package Preview Available!


Install this PR's preview build with npm:

npm i @base44-preview/cli@0.0.28-pr.201.978b427

Prefer not to change any import paths? Install using npm alias so your code still imports base44:

npm i "base44@npm:@base44-preview/cli@0.0.28-pr.201.978b427"

Or add it to your package.json dependencies:

{
  "dependencies": {
    "base44": "npm:@base44-preview/cli@0.0.28-pr.201.978b427"
  }
}

Preview published to npm registry — try new features instantly!

@claude
Copy link

claude bot commented Feb 7, 2026

Code Review

I found one issue that should be addressed:

Missing CLAUDE.md Documentation Update

File: CLAUDE.md (lines 638-646)
Issue: The "What's Captured" section should be updated to document the new API telemetry fields.

This PR adds automatic extraction of API request/response data from ApiError instances, introducing these new telemetry properties:

  • api_request_url - The API endpoint URL
  • api_request_method - HTTP method (GET, POST, PUT, etc.)
  • api_status_code - HTTP status code
  • api_response_body - The response body from the API

Why this matters:

  • This is an architectural change in how API errors are captured (from manual ErrorContext.api to automatic extraction)
  • CLAUDE.md Important Rule #10 states: "Keep AGENTS.md updated - Update this file when architecture changes"
  • The PR checklist item "I have updated AGENTS.md if I made architectural changes" is unchecked

Suggested fix:
Add this to the "What's Captured" section:

- API error details (automatically extracted from ApiError instances):
  - Request URL and HTTP method
  - Response status code
  - Response body

Summary: 1 issue found related to CLAUDE.md adherence. No bugs detected in the implementation.

@kfirstri kfirstri moved this from Backlog to In progress in CLI Development Feb 8, 2026
@kfirstri kfirstri merged commit 278a7c3 into main Feb 8, 2026
6 checks passed
@kfirstri kfirstri deleted the claude/enhance-error-reporter-mu1ZQ branch February 8, 2026 16:07
@github-project-automation github-project-automation bot moved this from In progress to Done in CLI Development Feb 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Post hog improvements

2 participants